package com.longge;

import java.util.HashSet;
import java.util.Set;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-09 03:31
 */
public class CountConsistentStrings {

    public int countConsistentStrings(String allowed, String[] words) {

        char[] chars = allowed.toCharArray();
        Set<Character> set = new HashSet<>();
        for (char aChar : chars) {
            set.add(aChar);
        }
        int count = 0;
        for (int i = 0; i < words.length; i++) {
            char[] charArray = words[i].toCharArray();
            for (int j = 0; j < charArray.length; j++) {
                if (!set.contains(charArray[j])) {
                    break;
                }
                if (j == charArray.length - 1) count++;
            }
        }
        return count;

    }
}
